package ch8.ex9;

import java.util.*;
import static ch8.print.Print.*;
import ch7.note.Note;

abstract class Instrument{
	void play(Note n){
		println(this + ".play() " + n);
	}
	public abstract String toString();
	void adjust(){
		println(this + ".adjust()");
	}
}

class Wind extends Instrument{
	public String toString(){
		return "Wind";
	}
}

class Percussion extends Instrument{
	public String toString(){
		return "Percussion";
	}
}

class Stringled extends Instrument{
	public String toString(){
		return "Stringled";
	}
}

class Brass extends Wind{
	public String toString(){
		return "Brass";
	}
}

class Woodwind extends Wind{
	public String toString(){
		return "Woodwind";
	}
}

class Electronic extends Instrument{
	public String toString(){
		return "Electronic";
	}
}

public class MusicRefactor {
	static Instrument[] i = {
			new Wind(),
			new Percussion(),
			new Stringled(),
			new Brass(),
			new Woodwind(),
			new Electronic()
	};
	
	static Random rand = new Random(47);
	
	static Instrument next(){
		switch(rand.nextInt(6)){
		default:
		case 0: return new Wind();
		case 1: return new Percussion();
		case 2: return new Stringled();
		case 3: return new Brass();
		case 4: return new Woodwind();
		case 5: return new Electronic();
		}
	}
	
	public static void printAll(Instrument... orch){
		
		for(int i = 0; i < orch.length; i++){
			orch[i] = next();
		}
		for(Instrument i:orch){
			println(i);
			i.adjust();
			i.play(Note.MIDDLE_C);
		}
	}
	
	public static void main(String... args){
		printAll(new Instrument[200]);
	}
}
